package pers.zb.cloud.web.upms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import pers.zb.cloud.web.upms.service.UserService;

/**
 * 用户业务
 */
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserService userService;

    /**
     * 根据用户名获取用户信息
     *
     * @param name 用户姓名
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/user/{name}",produces = "application/json;charset=UTF-8")
    public String getUserInfoByName(@PathVariable("name") String name) {
        return userService.getUserInfoByName(name);

        /*ResponseEntity<String> response = restTemplate.exchange("http://sea-cloud-service-user/user/user/" + name, HttpMethod.GET, null, String.class);
        return response.getBody();*/

    }
}
